#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+5;
int T;
int n,m,L,V;
int lst;
int v[maxn],a[maxn],d[maxn];
bool check(int S,int A,int V0){
    if(V0*V0+2*A*S>V*V) return 1;
    return 0;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",d+i,v+i,a+i);
        }
        for(int i=1;i<=m;i++) scanf("%lld",&lst);
        int cnt1=0;
        for(int i=1;i<=n;i++){
           if(lst>=d[i]&&check(lst-d[i],a[i],v[i])) cnt1++;
        }
        printf("%lld %lld\n",cnt1,cnt1 ? (m-1) : m);
    }
    return 0;
}
